package com.cjw;

import com.cjw.config.handler.UserContextHandler;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.EnableAspectJAutoProxy;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.transaction.annotation.EnableTransactionManagement;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import springfox.documentation.swagger2.annotations.EnableSwagger2;
import tk.mybatis.spring.annotation.MapperScan;

@SpringBootApplication
@EnableAspectJAutoProxy
@EnableSwagger2
@EnableTransactionManagement
@EnableScheduling
@MapperScan(basePackages = {"com.cjw.mapper.*"})
public class HealthSharingServerApplication implements WebMvcConfigurer {
    @Autowired
    private UserContextHandler userContextHandler;

    public static void main(String[] args) {
        SpringApplication.run(HealthSharingServerApplication.class, args);
    }

    /**
     * 注册自定义拦截器
     * @param registry
     */
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(userContextHandler).addPathPatterns("/**");
    }
}
